<div class="container main" ng-controller="QuoteListCtrl">
    <!-- 顶部功能区 -->
    <div class="row">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <div class="text-center"><strong>{[moduleTitle|uppercase]}</strong></div>
                <div class="row">
                    <div class="col-md-4">
                        <span class="btn-group">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
                                <strong>Actions</strong>&nbsp;&nbsp;<i class="caret"></i>
                            </button>

                            <ul class="dropdown-menu">
                                <li>
                                    <a ng-click="removeSelectedList(objects, query)" href="javascript:void(0);">Delete</a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a onclick="" href="javascript:void(0);">Import</a>
                                </li>
                                <li>
                                    <a onclick="" href="javascript:void(0);">Export</a>
                                </li>
                            </ul>

                        </span>
                        <span class="btn-group">
                            <button class="btn btn-primary pull-left" ng-click="addNew()">
                                <i class="glyphicon glyphicon-plus icon-white"></i> Add
                            </button>
                        </span>
                    </div>
                    <div class="col-md-8">
                        <form name="form_query" ng-submit="query()" class="form-inline pull-right">
                            <div class="form-group">
                                <label class="sr-only"></label>
                                <input type="text" class="form-control" ng-model="parameters.query" placeholder="Keywords" />
                            </div>

                            <div class="form-group">
                                <label class="sr-only"></label>
                                <select name="limit" ng-model="parameters.limit" class="form-control">
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                    <option value="0">Unlimited</option>
                                </select>
                            </div>
                            <button type="submit" class="btn btn-info">
                                <i class="glyphicon glyphicon-search icon-white"></i> Search
                            </button>
                        </form>
                    </div>
                </div>
            </div>

            <!-- Table -->
            <div ng-show="objects.length == 0" class="rounded_corners no_result">
                <p>No Quotes found. <a href="javascript:void(0)" ng-click="addNew()">Create Quote</a> </p>
            </div>
            <table class="table table-striped table-bordered table-condensed table-hover" ng-show="objects.length > 0" ts-wrapper>
                <thead>
                    <tr>
                        <th>
                            <select-all-checkbox checkboxes="objects" all-selected="AllSelectedItems"
                            all-clear="NoSelectedItems"></select-all-checkbox>
                        </th>
                        <th ts-criteria="subject">#</th>
                        <th ts-criteria="quote_stage_title">Quote Stage</th>
                        <th ts-criteria="contact_title">Contact Name</th>
                        <th ts-criteria="total">Total ($)</th>
                        <th ts-criteria="created_on">Created at</th>
                        <th ts-criteria="assigned_to_title">Assigned To</th>
                        <th>PO File</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="obj in objects" ts-repeat="ts-repeat">
                        <td class="text-center">
                            <input type="checkbox" ng-model="obj.isSelected" />
                        </td>
                        <td class="text-center">
                            <!--
                            <div class="pull-left"> <span class="badge badge-info" ng-show="obj.progress == 'order'">o</span>
                                <span class="badge badge-success" ng-show="obj.progress == 'invoice'">i</span>
                            </div>
                            -->
                            <a href="javascript:void(0)" ng-click="openQuoteDetail(obj.id)">{[ obj.subject ]}</a>
                        </td>
                        <td class="text-center">{[ obj.quote_stage_title ]}</td>
                        <td class="text-center">{[ obj.contact_title ]}</td>
                        <td class="text-center">{[ obj.total ]}</td>
                        <td class="text-center">{[ obj.created_on | fixDateTime ]}</td>
                        <td class="text-center">{[ obj.assigned_to_title ]}</td>
                        <td class="text-center">
                            <a ng-if="obj.poFileLink"
                               href="{[obj.poFileLink]}" target="_blank">
                                PO File
                            </a>
                            <div ng-if="!obj.poFileLink" class="btn btn-primary btn-xs" style="position: relative; overflow: hidden; direction: ltr;">
                                Upload PO
                                <input style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;"
                                       type="file" ng-file-select="uploadFiles($files, '/api/v1/quote/upload_po/',{'quoteId':obj.id})" name="attachment">
                            </div>
                        </td>
                        <td class="text-right">
                            <a class="btn btn-xs" href="/pdf?type=quote&amp;id={[ obj.id ]}" target="_blank">PDF</a>
                            <span class="btn-group">
                                <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">
                                    <strong>Actions</strong>&nbsp;&nbsp;<i class="caret"></i>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-1">
                                    <li class="text-left">
                                        <a ng-click="edit(obj.id)" href="javascript:void(0);">Edit</a>
                                    </li>
                                    <li class="text-left" ng-if="obj.progress == 'quote'">
                                        <a ng-click="quoteToOrder(obj.id)" href="javascript:void(0);">To Order</a>
                                    </li>
                                    <li class="text-left" ng-if="obj.poFileLink&&!obj.poReplyComment&&!obj.isPoValid" >
                                        <a ng-click="poCheckReply(obj)" href="javascript:void(0);">PO Reply</a>
                                    </li>
                                    <li class="text-left">
                                        <a ng-click="getMoreInfo('quote',obj.id)" href="javascript:void(0);">More Info</a>
                                    </li>
                                </ul>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div ng-include="'/static/js/views/components/pager.html'" style="display: inline;"></div>

</div>